from day01.basecla import BaseClass
from day01.basecla import driver
from selenium.webdriver.common.by import By
from time import sleep
url='file:///E:/%E8%93%AC%E8%8E%B1%E5%B0%8F%E8%AF%BE2024%E6%B5%8B%E8%AF%95/%E7%AC%AC%E5%9B%9B%E9%98%B6%E6%AE%B5/Selenium%E8%87%AA%E5%8A%A8%E5%8C%96/selenium_demo/day04demo/demo01.html'
c=BaseClass()
c.open_browser(url)
#准备数据
data={
    "name":"lili",
    "pwd":"12345",
    "check":"5432",
    "mobile":"123456778",
    "mesg":"hello"
}
locator=[By.ID,By.NAME,By.XPATH]
#定位页面元素
myname=driver.find_element_by_id('username')
mypassword=driver.find_element_by_name('password')
mycheck=driver.find_element(locator[2],'//input[@name="check"]')
mymobile=driver.find_element_by_xpath('//input[@name="mobile"]')
mymesg=driver.find_element_by_xpath('//textarea')
mysubmit=driver.find_element_by_css_selector('input#submit')
#操作页面元素
myname.clear()
myname.send_keys(data["name"])
sleep(2)
mypassword.send_keys(data['pwd'])
sleep(2)
mycheck.send_keys(data['check'])
sleep(2)
print(mycheck.is_enabled())
print(mymobile.is_enabled())


if mymobile.is_enabled()==True:
   mymobile.send_keys(data['mobile'])
mymesg.clear()
mymesg.send_keys(data['mesg'])
sleep(2)
mysubmit.click()
#driver.quit()
